package net.liteheaven.xplugin.demoplugin;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;

import net.liteheaven.conflict.ConflictUtil;
import net.liteheaven.xblib.plugin.XProxyActivity;

/**
 * 插件详情页
 * Created by LiangYu on 16/8/29
 */
public class PluginDetailActivity extends XProxyActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        @SuppressLint("InflateParams")
        View v = LayoutInflater.from(this).inflate(R.layout.activity_plugin_detail, null);
        setContentView(v);
        findViewById(R.id.iv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(v.getContext(), PluginHomeActivity.class));
            }
        });
        findViewById(R.id.popup).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupWindow();
            }
        });
        findViewById(R.id.toast).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ConflictUtil.showToast(PluginDetailActivity.this);
            }
        });
    }

    private void showPopupWindow(){
        TextView tv = new TextView(this);
        tv.setText("我是弹窗");
        tv.setTextSize(50);
        tv.setTextColor(Color.RED);
        tv.setBackgroundColor(Color.YELLOW);
        PopupWindow pw = new PopupWindow(tv, -2, -2);
        pw.setContentView(tv);
        pw.showAsDropDown(findViewById(R.id.iv));
    }
}
